package com.leo.springbootmultithreadbasic.lock.reentrantlock.basicdemo.demo2;

/**
 * @author Leo
 * @version V1.0
 * @date 2021/10/31 11:58 PM
 */
public class MainDemo {
    public static void main(String[] args) {
        test1();
    }


    /**
     * Test Scenario:1 Object
     *
     * Test Result: 调用lock.lock代码的线程就持有类对象监视器，其他线程只能等到锁被释放后才能争抢锁。
     */
    public static void test1() {
        MySerivce mySerivce = new MySerivce();
        MyThreadA myThreadA = new MyThreadA(mySerivce);
        myThreadA.setName("A");
        myThreadA.start();


        MyThreadB myThreadB = new MyThreadB(mySerivce);
        myThreadB.setName("B");
        myThreadB.start();

    }
}
